package com.eightbears.beboy.ui.chat.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.eightbears.beboy.R;
import com.eightbears.beboy.base.BaseActivity;
import com.eightbears.beboy.base.view.SwipeBackLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

public class EditActivity extends BaseActivity {
	private EditText editText;
	@BindView(R.id.sw_finish)
	SwipeBackLayout sw_finish;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(com.eightbears.beboy.R.layout.em_activity_edit);
		initView();
		initData();
		initEvent();
	}

	@Override
	protected void initView() {
		ButterKnife.bind(this);
		editText = (EditText) findViewById(R.id.edittext);
		String title = getIntent().getStringExtra("title");
		String data = getIntent().getStringExtra("data");
		if(title != null)
			((TextView)findViewById(com.eightbears.beboy.R.id.tv_title)).setText(title);
		if(data != null)
			editText.setText(data);
		editText.setSelection(editText.length());
	}

	@Override
	protected void initData() {

	}

	@Override
	protected void initEvent() {
		sw_finish.setCallBack(new SwipeBackLayout.CallBack() {
			@Override
			public void onFinish() {
				finish();
			}
		});
	}


	public void save(View view){
		setResult(RESULT_OK,new Intent().putExtra("data", editText.getText().toString()));
		finish();
	}

	public void back(View view) {
		finish();
	}
}
